package com.gist.cithub.service.service.impl;

import com.gist.cithub.service.entity.InforEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gist.common.utils.PageUtils;
import com.gist.common.utils.Query;

import com.gist.cithub.service.dao.AverageScoreDao;
import com.gist.cithub.service.entity.AverageScoreEntity;
import com.gist.cithub.service.service.AverageScoreService;


@Service("averageScoreService")
public class AverageScoreServiceImpl extends ServiceImpl<AverageScoreDao, AverageScoreEntity> implements AverageScoreService {
    @Autowired
    AverageScoreDao averageScoreDao;
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<AverageScoreEntity> page = this.page(
                new Query<AverageScoreEntity>().getPage(params),
                new QueryWrapper<AverageScoreEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public AverageScoreEntity getScoreByServiceId(Integer serviceId) {
        QueryWrapper<AverageScoreEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.and(
                wrapper ->
                        wrapper.eq("service_id", serviceId)
        );
        AverageScoreEntity res= averageScoreDao.selectOne(queryWrapper);
        return res;
    }

}